import Vue from 'vue';

/** 存在权限 **/
Vue.directive('auth', {
  inserted(el, binding) {
    let auth = binding.value.toLowerCase();
    if (localStorage.getItem('autoButton') && !(localStorage.getItem('autoButton').split(',').indexOf(auth) > -1)) {
      el.style.display = 'none';
    }
  }
});

/** 无权限显示 **/
Vue.directive('no-auth', {
  inserted(el, binding) {
    let auth = binding.value.toLowerCase();
    if (localStorage.getItem('autoButton').split(',').indexOf(auth) > -1) {
      el.style.display = 'none';
    }
  }
});

/** 供应商 **/
Vue.directive('supplier', {
  inserted(el, binding) {
    if (localStorage.getItem('userType') == 2) {
      //当前账号类似为供应商
      el.style.display = 'none';
    }
  }
});
